package com.xxxt.zpc.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.xxxt.dao.FeedbackMapper;
import com.xxxt.entity.Feedback;
import com.xxxt.entity.Inform;
import com.xxxt.entity.Student;
import com.xxxt.zpc.service.FeedbackService;
@Service
public class FeedbackServiceImpl implements FeedbackService{
	
	@Autowired
	FeedbackMapper feedback;
	@Override
	public boolean insertInform(String sno, String informId) {
		if(sno!=null&&informId!=null){
			return feedback.insertInform(sno, informId);
		}
		return false;
	}

	@Override
	public List<Integer> selectFeedbackList(List<Inform> list) {
		String[] informId=new String[list.size()];
		for(int i=0;i<list.size();i++){
			informId[i]=list.get(i).getInformId();
		}
		return feedback.selectFeedbackList(informId);
	}

	@Override
	public int selectStudentConut(String tno) {
		return feedback.selectStudentConut(tno);
	}

	@Override
	public Integer selectById(String informId) {
		
		return feedback.selectById(informId);
	}

	@Override
	public Feedback selectFeedbackBySnoAndId(String sno, String feedbackId) {
		
		Feedback feedbacka=this.feedback.selectFeedbackBySnoAndId(sno, feedbackId);
		
		if(feedbacka==null){
			this.feedback.insertInform(sno, feedbackId);
			
		}
		feedbacka=this.feedback.selectFeedbackBySnoAndId(sno, feedbackId);
		
		return feedbacka;
	}

	@Override
	public List<Feedback> selectFeedbackBySno(String sno) {
		
		return feedback.selectFeedbackBySno(sno);
	}

	@Override
	public List<Feedback> selectFeedbckById(String informId) {
		if(informId!=null&&!informId.equals("")){
			return feedback.selectFeedbckById(informId);
		}
		return null;
	}

	@Override
	public List<Student> selectStudent(String tno) {
		return feedback.selectStudent(tno);
	}

}
